package routers

import (
	"API/service/equipmen"
	"API/service/opd"
	"API/service/order"
	"API/service/product"
	"API/service/user"
	"common/global"
	"common/pkg"
	"github.com/gin-gonic/gin"
)

// LoadRouters 路由组

// InitUserRouter 初始化用户相关路由（含JWT保护）
func InitUserRouter(r *gin.Engine) {
	userGroup := r.Group("/user")
	{
		// 新增开放接口
		userGroup.POST("/register", user.RegisterHandler) // 注册接口
		userGroup.POST("/login", user.LoginHandler)       // 登录接口

		// 使用JWT中间件保护后续接口
		userGroup.Use(pkg.JWTAuth(global.JwtSecretKey))
		userGroup.POST("/luckyDraw", user.LuckyDrawHandler)         // 抽奖接口
		userGroup.POST("/upload", user.QiNiuYunUpload)              //文件上传
		userGroup.POST("/sign", user.SignInHandler)                 // 签到接口
		userGroup.POST("/retroactive", user.RetroactiveSignHandler) // 补签接口
		userGroup.POST("/realName", user.RealNameHandler)           // 实名接口
		userGroup.POST("/findLucky", user.FindLuckyHandler)         // 查找中奖记录接口
		userGroup.POST("/findSign", user.GetSignHandler)            // 查找签到记录接口
		userGroup.GET("/detail", user.GetUserDetail)                // 获取用户详情接口
	}
	productGroup := r.Group("/product")
	{
		productGroup.Use(pkg.JWTAuth(global.JwtSecretKey))
		productGroup.GET("/list", product.ListProduct)                            //商品列表查询
		productGroup.POST("/create/car", product.CreateCatProduct)                //添加商品到购物车
		productGroup.POST("/del/car", product.DelCarProduct)                      //移除商品购物车
		productGroup.POST("/update/car", product.UpdateCarProduct)                //修改购物车中商品的数量
		productGroup.POST("/clear/car", product.DelCar)                           //清空购物车
		productGroup.GET("/car/list", product.CarList)                            //购物车列表展示
		productGroup.POST("/checkout/car", product.CheckoutCar)                   //购物车结算
		productGroup.POST("/group/buy", product.CreateGroup)                      //创建拼团
		productGroup.GET("/group/detail", product.GetGroupDetail)                 //拼团详情
		productGroup.POST("group/parse", product.ParseTaoBao)                     //解析淘口令
		productGroup.POST("group/join", product.JoinGroup)                        //加入拼团
		productGroup.POST("/snapped/spikes", product.SnappedSpikesProduct)        //抢购秒杀商品
		productGroup.POST("/start/bargain", product.StartBargain)                 //用户发起砍价
		productGroup.POST("/help/bargain", product.HelpBargain)                   //用户帮忙砍价
		productGroup.GET("/query/bargain/progress", product.QueryBargainProgress) //用户砍价记录
		productGroup.POST("/bargain/settlement", product.BargainSettlement)       //用户砍价结算
		productGroup.GET("/spikes/list", product.SpikesProductList)               //秒杀商品列表
		productGroup.GET("/bargain/list", product.BargainProductList)             //砍价商品列表
		productGroup.GET("/info", product.ProductInfo)                            //商品详情
		productGroup.GET("/spikes/info", product.SpikesProductInfo)               //秒杀商品详情
		productGroup.GET("/bargain/info", product.BargainProductInfo)             //砍价商品详情

	}
	orderGroup := r.Group("/order")
	{
		orderGroup.POST("/callback", order.OrderUpdatePaid) // 回调支付
		orderGroup.Use(pkg.JWTAuth(global.JwtSecretKey))
		orderGroup.POST("/create", order.CreateOrder) //创建订单
		orderGroup.GET("/list", order.OrderList)      //订单列表展示
		orderGroup.GET("/info", order.OrderDetail)    //订单详情展示

	}
	opdGroup := r.Group("/opd")
	{
		opdGroup.Use(pkg.JWTAuth(global.JwtSecretKey))
		opdGroup.POST("/outpatientRegistration", opd.OutpatientRegistration)
		opdGroup.GET("/doctorList", opd.DoctorList)
		opdGroup.GET("/doctorInfo", opd.DoctorInfo)
		opdGroup.POST("/aiConsultation", opd.AiConsultation)
	}

	equipmentGroup := r.Group("/equipment") //设备服务相关接口
	{
		equipmentGroup.Use(pkg.JWTAuth(global.JwtSecretKey))
		equipmentGroup.POST("/bind/device", equipmen.BindDevice)             //设备绑定
		equipmentGroup.POST("/unbind/device", equipmen.UnBindDevice)         //设备解绑
		equipmentGroup.GET("/get/pdf", equipmen.GetPdf)                      //获取健康报告
		equipmentGroup.GET("/obtain/health/data", equipmen.ObtainHealthData) //查询设备检测数据
	}

}
